package com.sl.biz.modular.process.controller;

import com.sl.biz.modular.process.controller.request.ProcessRunnerKillRequest;
import com.sl.biz.modular.process.controller.request.ProcessRunnerStopRequest;
import com.sl.biz.modular.process.controller.response.ProcessRunnerInfoVO;
import com.sl.biz.modular.process.service.ProcessRunnerInfoBizService;
import lombok.RequiredArgsConstructor;
import org.simpleframework.xml.core.Validate;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/process/runner")
@RequiredArgsConstructor
public class ProcessRunnerInfoController {

    private final ProcessRunnerInfoBizService runnerInfoBizService;

    @PostMapping("/list")
    public List<ProcessRunnerInfoVO> list() {
        return runnerInfoBizService.list();
    }


    @PostMapping("/stop")
    public Boolean stop(@RequestBody @Validate ProcessRunnerStopRequest processRunnerStopRequest) {
        return runnerInfoBizService.stop(processRunnerStopRequest);
    }

    @PostMapping("/kill")
    public Boolean kill(@RequestBody @Validate ProcessRunnerKillRequest processRunnerStopRequest) {
        return runnerInfoBizService.kill(processRunnerStopRequest);
    }

}
